import java.util.*;

/**
 * Created with Intellij JDEA
 * Description:
 * User:
 * Date:2022-04-18
 * Time:9:34
 */
public class 字典序排数 {
    public List<Integer> lexicalOrder(int n) {
        List<Integer> ret = new ArrayList<>();
        int num = 1;
        for(int i = 0;i < n;i++) {
            ret.add(num);
            if(num * 10 <= n) {// <= 10;注意界限
                num *= 10;
            }else {
                while(num % 10 == 9 || num+1 > n) {
                    num /= 10;
                }
                num++;
            }
        }
        return ret;
    }


}
